<template>
	<view class="page">
		<view class="my-card" style="">
			<view class="text-white">
				<text v-if="!hasTask" class="zwrw">暂无任务</text>
				<view v-else>
					<view class="title_body">
						<text class="title">{{task.name}}</text>
						<button @click="see_detail(task.ucId)" class="cu-btn round my-btn">巡检</button>
					</view>
					<view class="content">
						<text>类型：{{task.name}}</text>
						<text>描述：{{task.remark}}</text>
						<text>巡检时间：{{task.startTime}}</text>
					</view>
				</view>
			</view>
		</view>
		<view class="utools">
			<text class="utools-title">任务管理</text>
			<view class="uk">
				<view style="" class="bg-1" @click="my_task">
					<text>我的任务</text>
				</view>
				<view style="" class="bg-2" @click="get_task">
					<text>任务领取</text>
				</view>
			</view>
		</view>

		<view class="utools">
			<text class="utools-title">火情管理</text>
			<view class="uk">
				<view style="" class="bg-3" @click="my_yjxx">
					<text>预警信息</text>
				</view>
				<view style="" class="bg-4" @click="my_hqxx">
					<text>火情信息</text>
				</view>
			</view>
		</view>

		<view class="utools">
			<text class="utools-title">预防演练</text>
			<view class="uk">
				<view style="" class="last_mk bg-5" @click="xfyh">
					<view class="uk_title">
						<text>消防隐患</text>
					</view>
				</view>
				<view class="last_mk bg-6" style="" @click="xfyl">
					<view class="uk_title">
						<text>消防演练</text>
					</view>
				</view>
				<view class="last_mk bg-7" style="" @click="fqyl">
					<view class="uk_title">
						<text>发起演练</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		created() {
			console.info("ahome create")

			this.getTask()

			let that = this
			uni.$on('refreshPage', function() {
				that.getTask()
			})
		},
		data() {
			return {
				hasTask: true,
				task: ''
			}
		},
		methods: {
			my_task() {
				uni.navigateTo({
					url: '/yzqy/rwlb/rwlb'
				})
			},
			get_task() {
				uni.navigateTo({
					url: '/yzqy/rwlq/rwlq'
				})
			},
			my_yjxx() {
				uni.navigateTo({
					url: '/yzqy/yjxxlb/yjxxlb'
				})
			},
			my_hqxx() {
				uni.navigateTo({
					url: '/yzqy/hqxxlb/hqxxlb'
				})
			},
			xfyh() {
				uni.navigateTo({
					url: '/yzqy/xfyhlb/xfyhlb'
				})
			},
			xfyl() {
				uni.navigateTo({
					url: '/yzqy/xfyl/xfyl'
				})
			},
			fqyl() {
				uni.navigateTo({
					url: '/yzqy/fqyl/fqyl'
				})
			},
			see_detail(ucId) {
				uni.navigateTo({
					url: '/yzqy/rwxq/rwxq?ucId=' + ucId
				})
			},
			getTask() {
				let that = this
				let params = {
					"pageNum": 1,
					"pageSize": 1,
					"status": 1
				}
				// 请求数据
				let app = getApp()
				app.globalData.request({
					url: 'wx/taskmanage/getMyTaskEnterprisePage',
					data: {
						...params
					}
				}).then(function(res) {
					if (res.data.data.list.length > 0) {
						that.hasTask = true
						that.task = res.data.data.list[0]
					} else {
						that.hasTask = false
					}

				}).catch(function(e) {
					that.hasTask = false
				})
			}
		}
	}
</script>

<style scoped>
	.page {
		margin: 0 24rpx;
		margin-top: 39rpx;
		height: 400px;
	}

	.my-card {
		height: 320rpx;
		border-radius: 25upx;
		padding: 24upx 50upx;
		background: url('https://tva3.sinaimg.cn/large/005Tv2WXgy1h0l69wi2hrj309r04g74o.jpg') no-repeat;
		background-size: cover;
	}

	.title_body {
		font-family: PingFangSC-Medium;
		font-size: 36rpx;
		color: #FFFFFF;
		text-align: left;
		margin: 40upx 0;

	}

	.my-btn {
		float: right;
		font-size: 24rpx;
		color: #FCAA19;
		height: 50rpx;
	}

	.content {
		font-family: PingFangSC-Medium;
		font-size: 24rpx;
		color: #FFFFFF;
		letter-spacing: 0.39px;
		text-align: left;
		line-height: 24rpx;
		display: flex;
		flex-direction: column;
	}

	.content text {
		margin: 6px 0;
	}

	.utools {
		margin-top: 40upx;
	}

	.utools-title {
		font-size: 32rpx;
		color: #777777;
		font-weight: 600;
	}

	.uk {
		display: flex;
		justify-content: space-between;
		flex-direction: row;
		margin-top: 20upx;
	}

	.uk view {
		flex: 1;
		height: 105rpx;
		border-radius: 8px;
	}

	.uk .last_mk {
		height: 170rpx;
		/* border-radius: 8px; */
	}

	.uk text {
		display: flex;
		justify-content: center;
		align-items: center;
		height: 100%;
		padding-left: 90rpx;
		font-size: 28rpx;
		color: #777777;
		font-weight: 600;
	}

	.uk .last_mk text {
		height: 160rpx;
		color: #777777;
		display: flex;
		padding-left: 0;
		flex-direction: row;
		align-items: flex-end;
	}

	.bg-1 {
		background: url(@/static/home/dHome/icon_renwulingqu.png) no-repeat -2px -4px;
		background-size: cover;
	}

	.bg-2 {
		background: url(@/static/home/dHome/icon_renwulingqu.png) no-repeat -2px -4px;
		background-size: cover;
	}

	.bg-3 {
		background: url(@/static/home/dHome/icon_yujingxinxi.png) no-repeat -2px -4px;
		background-size: cover;
	}

	.bg-4 {
		background: url(@/static/home/dHome/icon_huoqingxinxi.png) no-repeat -2px -4px;
		background-size: cover;
	}

	.bg-5 {
		background: url(@/static/home/dHome/icon_xiaofangyinhuan.png) no-repeat -2px -4px;
		background-size: cover;
	}

	.bg-6 {
		background: url(@/static/home/dHome/icon_xiaofangyanlian.png) no-repeat -2px -4px;
		background-size: cover;
	}

	.bg-7 {
		background: url(@/static/home/dHome/icon_faqiyanlian.png) no-repeat -2px -4px;
		background-size: cover;
	}

	.zwrw {
		font-size: 48rpx;
	}
</style>
